package com.cnswhy.cloud.server.iot.config;

import com.cnswhy.cloud.common.core.entity.constant.CnswhyConstant;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.util.Base64Utils;

public class FeignConfig  implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {

        byte[] token = Base64Utils.encode((CnswhyConstant.GATEWAY_TOKEN_VALUE).getBytes());
        //ServerHttpRequest build = exchange.getRequest().mutate().header(CnswhyConstant.GATEWAY_TOKEN_HEADER, new String(token)).build();
        //ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        /*HttpServletRequest request = attributes.getRequest();
        String token = request.getHeader(HttpHeaders.AUTHORIZATION);*/
        requestTemplate.header(CnswhyConstant.GATEWAY_TOKEN_HEADER, new String(token));

    }
}
